package com.ruoyi.project.museums.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.museums.domain.UserAnswer;
import com.ruoyi.project.museums.mapper.UserAnswerMapper;
import com.ruoyi.project.museums.service.IUserAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName questionServiceImpl
 * @Description 问题Service业务层处理
 * @Version 1.0
 */
@Service
public class UserAnswerServiceImpl implements IUserAnswerService{
    @Autowired
    private UserAnswerMapper userAnswerMapper;

    /**
     * 查询用户回答列表
     *
     * @param userAnswer 用户回答
     * @return 用户回答
     */
    @Override
    public List<UserAnswer> selectUserAnswerList(UserAnswer userAnswer)
    {
        return userAnswerMapper.selectUserAnswerList(userAnswer);
    }

    /**
     * 根据用户id查询用户回答
     *
     * @param id 用户回答主键
     * @return 用户回答
     */
    @Override
    public UserAnswer selectUserAnswerById(Long id)
    {
        return userAnswerMapper.selectUserAnswerById(id);
    }

    /**
     * 根据用户名称查询用户回答
     *
     * @param userName 用户名称
     * @return 用户回答
     */
    @Override
    public  UserAnswer selectUserAnswerByUserName(String userName)
    {
        return userAnswerMapper.selectUserAnswerByUserName(userName);
    }

    /**
     * 新增用户
     *
     * @param userAnswer 用户
     * @return 结果
     */
    @Override
    public int insertUserAnswer(UserAnswer userAnswer)
    {
        userAnswer.setCreateTime(DateUtils.getNowDate());
        return userAnswerMapper.insertUserAnswer(userAnswer);
    }

    /**
     * 修改用户信息
     *
     * @param userAnswer 用户信息
     * @return 结果
     */
    @Override
    public int updateUserAnswer(UserAnswer userAnswer)
    {
        userAnswer.setUpdateTime(DateUtils.getNowDate());
        return userAnswerMapper.updateUserAnswer(userAnswer);
    }
}
